import React, { Component } from 'react';
import {
	StyleSheet, Text, View, Image,
} from "react-native";
import { GLOBAL } from '../../../../config/global';
import { style } from '../../../../theme/style';
const scale = GLOBAL.SCALE;
export class HeadView extends Component {
	constructor(props) {
		super(props);
		this.state = {
			tabIndex: 0
		}
	}
	_setTabIndex = (num) => {
		this.setState({
			tabIndex: num
		}, function () {
			this.props.fatherHandle(num)
		});
	}
	render () {
		let { tabIndex } = this.state;
		return (
			<View style={styles.headBox}>
				<Text onPress={() => { this._setTabIndex(0) }} style={[styles.headTitle, tabIndex == 0 ? styles.active : null]}>采购</Text>
				<Text onPress={() => { this._setTabIndex(1) }} style={[styles.headTitle, tabIndex == 1 ? styles.active : null]}>销售</Text>
			</View>
		)
	}
}
const styles = StyleSheet.create({
	headBox: {
		flexDirection: 'row',
		justifyContent: 'center',
		width: '100%',
	},
	headTitle: {
		fontSize: 18 * scale,
		paddingLeft: 5 * scale,
		paddingRight: 5 * scale,
		lineHeight: 48 * scale
	},
	active: {
		borderBottomWidth: 2 * scale,
		borderStyle: 'solid',
		borderBottomColor: style.color.themeColor,
		color: style.color.themeColor
	}

})